package handler;

import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfPTable;
import vo.TicketVO;

import java.io.*;

public interface TicketService {
    int LOCAL_FILE = 0;//本地文件
    int NETWORK = 1;//网络文件

    default OutputStream getOutputStream(int outType) throws Exception {
        if(LOCAL_FILE == outType){
            return new FileOutputStream(System.getProperty("user.dir") + File.separator + "test.pdf");//输出到本地
        }else{
            return new ByteArrayOutputStream();//输出成二进制，做网络传输
        }
    }

    default OutputStream getOutputStream(int outType,String target) throws Exception {
        if(LOCAL_FILE == outType){
            return new FileOutputStream(target);//输出到本地
        }else{
            return new ByteArrayOutputStream();//输出成二进制，做网络传输
        }
    }

    PdfPTable createMainTable(int tableWidth, TicketVO ticketVO) throws Exception;
    Paragraph createTitle() throws Exception;
}
